package com.tanhua.server.controller;

import com.tanhua.domain.vo.RecommendQueryVo;
import com.tanhua.server.service.TodayBestService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 今日佳人控制器
 */
@RestController
@RequestMapping("/tanhua")
@Slf4j
public class TodayBestController {

    @Autowired
    private TodayBestService todayBestService;

    /**
     * 今日佳人
     * 接口路径：GET/tanhua/todayBest
     */
    @GetMapping("todayBest")
    public ResponseEntity<Object> todayBest() {
        log.info("今日佳人");
        return todayBestService.queryTodayBest();
    }

    /**
     * 接口名称：推荐朋友
     * 接口路径：GET/tanhua/recommendation
     */
    @GetMapping("recommendation")
    public ResponseEntity<Object> recommendation(RecommendQueryVo param) {
        log.info("接口名称：推荐朋友");
        return todayBestService.queryRecommendation(param.getPage(), param.getPagesize());
    }

    /**
     * 佳人信息
     * 接口路径：GET/tanhua/:id/personalInfo
     */
    @GetMapping("{id}/personalInfo")
    public ResponseEntity<Object> queryPersonalInfo(@PathVariable Long id) {
        log.info("佳人信息");
        return todayBestService.queryPersonalInfo(id);
    }

    /**
     * 查询陌生人问题
     * 接口路径：GET/tanhua/strangerQuestions
     */
    @GetMapping("strangerQuestions")
    public ResponseEntity<Object> strangerQuestions(Long userId) {
        log.info("查询陌生人问题");
        return todayBestService.strangerQuestions(userId);
    }

    /**
     * 回复陌生人问题
     * 接口路径：POST/tanhua/strangerQuestions
     */
    @PostMapping("strangerQuestions")
    public ResponseEntity<Object> replyQuestion(@RequestBody Map<String, Object> map) {
        log.info("回复陌生人问题");
        Integer userId = (Integer) map.get("userId");
        String reply = (String) map.get("reply");
        return todayBestService.replyQuestion(userId, reply);
    }

    /**
     * 接口名称：搜附近
     * 接口路径：GET/tanhua/search
     */
    @GetMapping("search")
    public ResponseEntity<Object> searchNear(String gender, Long distance){
        return todayBestService.searchNear(gender, distance);
    }

    /**
     * 探花-左滑右滑
     * @return
     */
    @GetMapping("/cards")
    public ResponseEntity<Object> cards(){
        log.info("探花-左滑右滑");
        return todayBestService.findCards();
    }

    /**
     * 探花-喜欢
     * @param likeUserId 被喜欢的人id
     * @return
     */
    @GetMapping("/{id}/love")
    public ResponseEntity<Object> love(@PathVariable("id") Long likeUserId){
        log.info("探花-喜欢");
        return todayBestService.love(likeUserId);
    }

    /**
     * 探花-不喜欢
     * @param likeUserId
     * @return
     */
    @GetMapping("/{id}/unlove")
    public ResponseEntity<Object> unlove(@PathVariable("id") Long likeUserId){
        log.info("探花-不喜欢");
        return todayBestService.unlove(likeUserId);
    }



}
